package br.ufal.tci.nexos.arcolive.service.connection.command;

import br.ufal.tci.nexos.arcolive.command.ArCoLIVEClientCommand;
import br.ufal.tci.nexos.arcolive.command.ArCoLIVECommandResult;
import br.ufal.tci.nexos.arcolive.participant.ArCoLIVEParticipant;
import br.ufal.tci.nexos.arcolive.protocol.ArCoLIVEConnectionProtocol;
import br.ufal.tci.nexos.arcolive.service.connection.ConnectionRequest;

public class SendDatabaseErrorMessageCommand extends ArCoLIVEClientCommand {

	public SendDatabaseErrorMessageCommand(ConnectionRequest request) {
		super(request);
	}

	protected ArCoLIVECommandResult executeImpl() {
		ArCoLIVEParticipant participant = (ArCoLIVEParticipant)this.request.getOwner();
		int requestId = this.request.getIntegerParameter("requestId").intValue();
		String response = ArCoLIVEConnectionProtocol.ID + "#requestId=" + requestId + "#response=" + ArCoLIVEConnectionProtocol.DATABASE_ERROR + "#cause=803";
		participant.getConnectionService().getConnection().sendMessage(response);
		
		return new ArCoLIVECommandResult(this, "");
	}

}